#include <bits/stdc++.h>
using namespace std;
int n;
int ans = INT_MAX;
int a[10000005] = {};
int cnt[10000005] = {};
set <int> s;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
        s.insert(a[i]);
        cnt[a[i]]++;
    }
    if(s.size() == 2)
    {
        auto it = s.begin();
        int i = *(it);
        int j = *(++it);
        if(cnt[i] >= cnt[j])
            printf("%d",cnt[i]);
        else
            printf("%d",cnt[j]);
        return 0;
    }
    for(auto i : s)
    {
        int prd = 0;
        int hrb = 0;
        for(auto j : s)
        {
            if(j == i)
                break;
            hrb += cnt[j];
        }
        prd = n - hrb;
        if(prd >= hrb)
            ans = min(ans,prd);
        else
            ans = min(ans,n - prd);
    }
    printf("%d",ans);
    fclose(stdin);
    fclose(stdout);
    return 0;
}
